package com.lz.sentinel.common.constant;

import java.util.Arrays;
import java.util.Locale;

public class PermConstant {



    public static interface  AUTH_TYPE{
        /**账户权限*/
        public static String ACCOUNT="ACCOUNT";
        /**组合权限*/
        public static String GROUP="GROUP";
        /**定价配置权限*/
        public static String CONFIG="CONFIG";
        /**利率曲线权限*/
        public static String IRCURVE="IRCURVE";
        /**红利率曲线权限*/
        public static String DIVCURVE="DIVCURVE";
        /**波动率曲线权限*/
        public static String VLSCURVE="VLSCURVE";
    }
    /**
     * 期权类型
     */
    public enum PERM_TYPE {
        ACCOUNT("ACCOUNT", "acc_id","acc_flag","accRight","tacc"),
        GROUP("GROUP", "group_id","group_flag","groupRight","tgroup"),
        CONFIG("CONFIG", "cfg_id","cfg_flag","cfgRight","tpric_cfg"),
        IRCURVE("IRCURVE", "irc_code","irc_flag","ircRight","tircurve"),
        DIVCURVE("DIVCURVE", "div_code","div_flag","divRight","tdivyield"),
        VLSCURVE("VLSCURVE", "vls_code","vls_flag","vlsRight","tvolsurface");

        private String type; //类型
        private String keyItem;//主键
        private String flagItem;//
        private String rightItem;//权限字段
        private String tableName;//主表名

        public String getType(){return type;}
        public void setType(String type){ this.type=type;}

        public String getKeyItem() {
            return keyItem;
        }

        public void setKeyItem(String keyItem) {
            this.keyItem = keyItem;
        }

        public String getFlagItem() {
            return flagItem;
        }

        public void setFlagItem(String flagItem) {
            this.flagItem = flagItem;
        }

        public String getRightItem() {
            return rightItem;
        }

        public void setRightItem(String rightItem) {
            this.rightItem = rightItem;
        }

        public String getTableName() { return tableName;}
        public void setTableName(String tableName) {this.tableName = tableName;}

        PERM_TYPE(String type, String keyItem,String flagItem,String rightItem,String tableName) {
            this.type = type;
            this.keyItem = keyItem;
            this.flagItem = flagItem;
            this.rightItem = rightItem;
            this.tableName = tableName;
        }

        public static PERM_TYPE getPermType(String type) {
            return Arrays.asList(PERM_TYPE.values()).stream()
                    .filter(permType -> permType.getType().toLowerCase(Locale.ROOT).equals(type.toLowerCase(Locale.ROOT)))
                    .findFirst().orElse(null);
        }

    }

}


